(function(){
	
	Ext.define('NetShopping.goods.GoodsShoppingGridStore',{
		extend:'Ext.data.Store',
		autoLoad: true,
		fields: [
			{name:'id'},
			{name:'goodsName'},
			{name:'goodsCode'},
			{name:'goodsPrice'},
			{name:'goodsUnit'},
			{name:'goodsInfo'},
			{name:'goodsNum'},
			{name:'createTime'},
			{name:'isUse'}
		],
		pageSize:20,
	    proxy: {
	        type: 'ajax',
	        url: '/goods/queryGoodsBaseIndex.do',
	        reader: {
	            type: 'json',
	            root: 'objectList',
	            totalProperty:'allCount'
	        }
	    }
	});
	
	Ext.define('NetShopping.goods.GoodsShoppingGrid',{
		extend:'Ext.panel.Panel',
		alias:'widget.goodsshoppinggrid',
		layout:'fit',
		requires:['NetShopping.goods.GoodsBaseGrid'],
		items:[
			{
				btConfig:{//默认按钮
					add:false,
					edit:false,
					del:false,
					refresh:false
				},
				xtype:'goodsbasegrid',
				gridStore:'NetShopping.goods.GoodsShoppingGridStore',
				listeners:{
					itemcontextmenu:function( me, record, item, index, e, eOpts ){
						e.preventDefault();    
					    e.stopEvent();// 取消浏览器默认事件    
					    console.log(123);
					    var record = record.raw;
					    var items = [{
							text : '加入购物车',
							icon:'resources/button/add.png',
							handler : function() {
								var params = {
									goodsId:record.id,
									goodsName:record.goodsName,
									goodsNum:1
								};
								Ext.Ajax.request({
								    url: '/goodsShoppingcart/save.do',
								    params: params,
								    success: function(response){
								    	Ext.Msg.alert('提示','加入成功')
								    }
								});
							}
						}];
					    var nodemenu = new Ext.menu.Menu({
							items:items
						});    
					    nodemenu.showAt(e.getXY());// 菜单打开的位置
					}
				}
			}
		]
	})
})()

